package cn.enjoy.rocketmq.util;

import cn.enjoy.rocketmq.component.MqComponent;
import cn.enjoy.rocketmq.constant.MqTagConstant;
import cn.enjoy.rocketmq.entity.ComMsg;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author K
 */
@Component
public class MqUtil {
    @Autowired
    private MqComponent mqComponent;
    @Autowired
    private ObjectMapper objectMapper;


    /**
     *
     */
    public void sendAsyncMessage(ComMsg codeReq) throws JsonProcessingException {
        mqComponent.sendAsyncMessage(objectMapper.writeValueAsBytes(codeReq), MqTagConstant.ORDER);
    }

}
